<!--#Include File="../conn.asp" -->
<!--#Include File="comm/inc.asp" -->
<%
'====================================================================
'= Team Elite - Elite Article System
'= Copyright (c) 2005 - 2006 Eason Chan All Rights Reserved.
'=-------------------------------------------------------------------
'= 版权协议：
'=	GPL (The GNU GENERAL PUBLIC LICENSE Version 2, June 1991)
'=-------------------------------------------------------------------
'= 文件名称：/Manager/Admin_Ip.asp
'= 摘    要：后台-IP管理文件
'=-------------------------------------------------------------------
'= 最后更新：eason007
'= 最后日期：2005-12-21
'====================================================================

Call EA_Manager.Chk_IsMaster

If Not EA_Manager.Chk_Power(Admin_Power,"32") Then 
	ErrMsg=str_Comm_NotAccess
	Call EA_Manager.Error(1)
End If

Dim Atcion
Atcion=Request.QueryString ("atcion")

Select Case LCase(Atcion)
Case "save"
	Call Save
Case "del"
	Call del
Case "add"
	Call Add
Case Else
	Call Main
End Select
Call EA_Pub.Close_Obj
Set EA_Pub=Nothing

Sub Main
	Dim Count,PageCount,Page,OutStr,i
	Dim FieldName(0),FieldValue(0)
	Dim WStr,TopicList
	Dim Temp,ListBlock
	
	Page=EA_Pub.SafeRequest(3,"page",0,1,0)

	PageContent=Template.LoadTemplate("admin_ip_list.htm")


	Template.SetVariable "Language_Comm_ListEmpty",str_Comm_ListEmpty,PageContent
	Template.SetVariable "Language_Comm_Bar_Operation",str_Comm_Bar_Operation,PageContent
	Template.SetVariable "Language_Comm_Edit_Operation",str_Comm_Edit_Operation,PageContent
	Template.SetVariable "Language_Comm_Alert_Del_Operation",str_Comm_Alert_Del_Operation,PageContent
	Template.SetVariable "Language_Comm_Del_Operation",str_Comm_Del_Operation,PageContent

	Template.SetVariable "Language_OperationNotice",str_OperationNotice,PageContent
	Template.SetVariable "Language_IP_Help",str_IP_Help,PageContent

	Template.SetVariable "Language_IP_IpList",str_IP_IpList,PageContent
	Template.SetVariable "Language_IP_AddIp",str_IP_AddIp,PageContent

	Template.SetVariable "Language_IP_IPHead",str_IP_IPHead,PageContent
	Template.SetVariable "Language_IP_IPFoot",str_IP_IPFoot,PageContent
	Template.SetVariable "Language_IP_OverTime",str_IP_OverTime,PageContent


	ListBlock=Template.GetBlock("list",PageContent)

	Count=EA_M_DBO.Get_Ip_Total()(0,0)
	If Count>0 Then 
		Template.SetVariable "ListTempty","none",PageContent

		TopicList=EA_M_DBO.Get_IP_List(Page,15)
	
	    For i=0 To Ubound(TopicList,2)
			Temp=ListBlock
  
			Template.SetVariable "IP_ID",TopicList(0,i),Temp
			Template.SetVariable "IP_Head",EA_Manager.ShowIp(TopicList(1,i)),Temp
			Template.SetVariable "IP_Foot",EA_Manager.ShowIp(TopicList(2,i)),Temp
			Template.SetVariable "IP_OverTime",TopicList(3,i),Temp

			Template.SetBlock "list",Temp,PageContent
		Next

		Template.SetVariable "PageListNav",EA_Manager.PageList(15,Count,Page,FieldName,FieldValue),PageContent
	End If
	Template.CloseBlock "list",PageContent


	Template.BaseReplace PageContent
	Template.OutStr PageContent
End Sub

Sub Add
	Dim PostId,Temp
	Dim Head,Foot
	
	PostId=EA_Pub.SafeRequest(3,"postid",0,0,0)

	PageContent=Template.LoadTemplate("admin_ip_option.htm")
	
	Temp=EA_M_DBO.Get_IP_Info(PostId)
	If IsArray(Temp) Then 
		Head=EA_Manager.SplitIp(Temp(1,0))
		Foot=EA_Manager.SplitIp(Temp(2,0))

		Template.SetVariable "IP_ID",PostId,PageContent

		Template.SetVariable "Head_A",Head(0),PageContent
		Template.SetVariable "Head_B",Head(1),PageContent
		Template.SetVariable "Head_C",Head(2),PageContent
		Template.SetVariable "Head_D",Head(3),PageContent
		Template.SetVariable "Foot_A",Foot(0),PageContent
		Template.SetVariable "Foot_B",Foot(1),PageContent
		Template.SetVariable "Foot_C",Foot(2),PageContent
		Template.SetVariable "Foot_D",Foot(3),PageContent

		Template.SetVariable "OverTime",Temp(3,0),PageContent
	End If

	Template.SetVariable "Language_Comm_Save_Button",str_Comm_Save_Button,PageContent
	Template.SetVariable "Language_Comm_Reset_Button",str_Comm_Reset_Button,PageContent

	Template.SetVariable "Language_OperationNotice",str_OperationNotice,PageContent
	Template.SetVariable "Language_IP_Help",str_IP_Help,PageContent

	Template.SetVariable "Language_IP_IpList",str_IP_IpList,PageContent
	Template.SetVariable "Language_IP_AddIp",str_IP_AddIp,PageContent

	Template.SetVariable "Language_IP_InputIp",str_IP_InputIp,PageContent
	Template.SetVariable "Language_IP_IPHead",str_IP_IPHead,PageContent
	Template.SetVariable "Language_IP_IPFoot",str_IP_IPFoot,PageContent
	Template.SetVariable "Language_IP_OverTime",str_IP_OverTime,PageContent


	Template.BaseReplace PageContent
	Template.OutStr PageContent
End Sub

Sub Del
	Call EA_Pub.Chk_Post
	
	Dim PostId
	PostId=EA_Pub.SafeRequest(3,"postid",0,0,0)

	EA_M_DBO.Set_IP_Delete PostId
	
	Call EA_Pub.Close_Obj
	Set EA_Pub=Nothing
	
	Response.Redirect Request.ServerVariables("HTTP_REFERER")
End Sub

Sub Save
	Call EA_Pub.Chk_Post
	
	Dim Ip_Head,Ip_Foot,OverTime
	Dim PostId
	
	PostId=EA_Pub.SafeRequest(3,"postid",0,0,0)
	Ip_Head=EA_Pub.SafeRequest(2,"head",1,"",0)
	Ip_Foot=EA_Pub.SafeRequest(2,"foot",1,"",0)
	OverTime=EA_Pub.SafeRequest(2,"date",2,Date()+3,0)
	Ip_Head=Replace(Ip_Head,", ",".")
	Ip_Foot=Replace(Ip_Foot,", ",".")
	Ip_Head=EA_Pub.FormatIp(Ip_Head)
	Ip_Foot=EA_Pub.FormatIp(Ip_Foot)

	If Rs.State=1 Then rs.Close
	If PostId<>0 Then
		Sql="Select * From [NB_IP] Where [Id]="&PostId
		rs.Open Sql,Conn,2,2
	Else
		rs.Open "NB_IP",Conn,2,2
		rs.AddNew
	End If
		rs("Head_Ip")=Ip_Head
		rs("Foot_Ip")=Ip_Foot
		rs("OverTime")=OverTime
		rs.update
	Rs.Close:Set Rs=Nothing
	
	Call EA_Pub.Close_Obj
	Set EA_Pub=Nothing
	
	Response.Redirect "Admin_ip.asp"
End Sub
%>